import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { SkillItem } from "../skill/SkillItem";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { LevelLimitDefin } from "../../../common/defin/LevelLimitDefin";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SkillLevelGetInfo } from "../../resource/info/SkillLevelGetInfo";
import { GButton } from "../../../../com/mui/controls/GButton";
//class FishLearnWindow
    
    export  class FishLearnWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            titleHeight = 26;
            setSize(263, 194);
            title = Language.getString(41517);
            this._textFormatDisabled = new GTextFormat(FontUtil.songtiName, 12, 16711680);
            ObjCreate.createBg(17, 38, 228, 144, this);
            this._itemBg = GlobalClass.getBitmap(ImagesConst.ItemBg);
            this._itemBg.x = 50;
            this._itemBg.y = 45;
            this.addChild(this._itemBg);
            this._skillItem = new SkillItem();
            this._skillItem.x = 53;
            this._skillItem.y = 48;
            this._skillItem.isDragAble = false;
            this.addChild(this._skillItem);
            this._tfName = ObjCreate.createTextField(Language.getString(41518), 105, 52, 100, 20, this, GlobalStyle.textFormat6);
            this._tfNeedLevel = ObjCreate.createTextField(Language.getStringByParam(41519, LevelLimitDefin.FishingLimitLevel.toString()), 105, 78, 100, 20, this, this._textFormatDisabled);
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 11661311);
            loc1.leading = 4;
            loc1.letterSpacing = 1;
            this._tfDescription = ObjCreate.createTextField(Language.getString(41520), 45, 102, 175, 40, this, loc1);
            this._tfDescription.wordWrap = true;
            this._btnGetAndUse = ObjCreate.createGButton(Language.getString(41517), 97, 145, 80, 28, this, "ButtonSpecial");
            this._btnGetAndUse.addEventListener(flash.events.MouseEvent.CLICK, this.onLearnSkill);
            return;
        }

        /* internal  */onLearnSkill(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._skillInfo) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.SkillBaseLearnReq, this._skillInfo.skillId));
            }
            this.hide();
            return;
        }

        public set isCanLearn(arg1: Boolean)
        {
            this._isCanLearn = arg1;
            this._btnGetAndUse.enabled = this._isCanLearn;
            if (this._isCanLearn) 
            {
                this._tfNeedLevel.setTextFormat(GlobalStyle.textFormat5);
            }
            else 
            {
                this._tfNeedLevel.setTextFormat(this._textFormatDisabled);
            }
            return;
        }

        public updateData(arg1: SkillLevelGetInfo): void
        {
            this._skillInfo = arg1;
            this._skillItem.data = this._skillInfo.skillInfo;
            this._skillItem.toolTipData = this._skillInfo.toolTipData;
            this._tfName.text = this._skillInfo.showName;
            this._tfNeedLevel.text = Language.getStringByParam(41519, this._skillInfo.needLevel.toString());
            this._tfDescription.text = this._skillInfo.showInfo;
            return;
        }

        public /* override */ hide(): void
        {
            this._skillInfo = null;
            super.hide();
            return;
        }

        /* internal */ /* var */_skillInfo: SkillLevelGetInfo;

        /* internal */ /* var */_itemBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_skillItem: SkillItem;

        /* internal */ /* var */_tfName: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfNeedLevel: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfDescription: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnGetAndUse: GButton;

        /* internal */ /* var */_textFormatDisabled: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_isCanLearn: Boolean;
    }
